IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[SelectAllDepartamento]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[SelectAllDepartamento]
GO

CREATE PROCEDURE [dbo].[SelectAllDepartamento]
	@MostrarTodo bit
AS
BEGIN
	SET NOCOUNT ON
	
	IF @MostrarTodo = 1
		BEGIN
			SELECT
			[IdDepartamento],
			[Nombre],
			[Estado]
			FROM [Departamento]
		END
	ELSE
		BEGIN
			SELECT
			[IdDepartamento],
			[Nombre],
			[Estado]
			FROM [Departamento]
			WHERE [Estado] = 1
		END

	SET NOCOUNT OFF
END

GO
